<?php
//
// +--------------------------------------+
// |PHP version 5.6
// +--------------------------------------+
// |短信验证码api
// +--------------------------------------+
// |2018-01-17
// +--------------------------------------+
// |潘龙兵
// +--------------------------------------+
// |知果汇短信接口管理
// +--------------------------------------+
//
namespace app\api\controller;
use think\View;
use think\Controller;
use think\Db;
use app\data\Data;
use app\api\model\Common;
use app\api\controller\Message;
class Forget extends Index {
    /*
    * @知果汇前台
    * @注册
    * @2018-02-02
    * @潘龙兵
    * @$add:注册数据
    *  $token:登录标识
    *  $data:返回数据
    */
    public function reset(){ 
      if(!isset($_GET['message']) || !isset($_GET['password']) || !isset($_GET['status'])){
        $this->_jsonp("1000","参数错误",null);
      }
      $password = $_GET['password'];

      $_data = model('Common')->pwd($password); 
      // echo 456;exit;
      $data   = json_decode($_data,true);
      $msg = $_GET['message']; 
      $status = $_GET['status'];
      if($status == 0){
        $where['phone'] = $msg;
        $name = '手机号';
      }else{
        $where['email'] = $msg;
        $name = '邮箱';
      }
      $zgh_user = new Data('user');
      $count = $zgh_user->count($where);
      if($count == 0) $this->_jsonp("1000","该".$name."还未注册",null);
      $res = $zgh_user->_update($data,$where);
      // dump($res);exit;
      if($res === false) $this->_jsonp("1000","重置密码失败",null);
        action_log_index('重置密码', 'log_ment', 1);
      $this->_jsonp("200","重置密码成功",null);
    }



}